#pragma once 

#include <string>

struct sqlite3_stmt;
struct sqlite3;

namespace helper {
namespace sqlite {
namespace detail {

class Statement {
public:
  Statement(sqlite3_stmt * stmt);
  ~Statement();

  int step();
  int reset();

  int clearBindings();

  int bindInteger(int index, int64_t value);//64
  int bindDouble(int index, double value);
  int bindText(int index, const char * str, int64_t len); //64+utf-8
  int bindText(int index, const std::string & str);

  int bindBlob(int index, const char * bin, int64_t len); //64
  int bindBlob(int index, const std::string & bin);
  int bindZeroBlob(int index, int64_t len);//64

  int bindNull(int index);


  int64_t columnInteger(int index) const;
  double  columnDouble(int index) const;
  const void * columnBlob(int index) const;
  const unsigned char * columnText(int index) const; //utf-8

  int columnType(int index) const;
  int columnBytes(int index) const;
  int columnCount() const;

	const char * columnName(int index) const ;
	// select tab.col from ....; -> return tab.type_name
  const char * columnDeclareType(int index) const; //for result-set from select  or Null

	// enabled if compiled with SQLITE_ENABLE_COLUMN_METADATA 
  //const char * columnDatabaseName(int index) const;
  //const char * columnTableName(int index) const;
  //const char * columnOriginName(int index) const ; 

  sqlite3 * dbHandler() const;

	
	// pointer to a copy of original input sql
  const char * sql() const;
	// replace with binded value of input sql
	char * expandedSql() const;

	// return true if the stmt has been stepped at least once , 
	//	but neither run to completion or been reset
  bool isBusy() const;
	// return true if stmt is explain or explain query plan 
  bool isExplain() const;
	// determine if an stmt write the database
	bool isReadOnly() const;

  
//  bindValue();
//  columnValue();
//  bindParameterCount();
//  bindParameterIndex();
//  bindParameterName();
//  bindPointer();
//  normalizedSql(); // valid if SQLITE_ENABLE_NORMALIZE-ON
  void * raw() const ;
private:
  sqlite3_stmt * _stmt;
};

}//namespace detail
}//namespace sqlite
}//namespace helper
